package com.sskj.market.ui.activity;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.flyco.tablayout.SlidingTabLayout;
import com.flyco.tablayout.listener.OnTabSelectListener;
import com.sskj.common.adapter.MyFragmentPagerAdapter;
import com.sskj.common.base.App;
import com.sskj.common.rxbus2.RxBus;
import com.sskj.lib.RConfig;
import com.sskj.lib.base.BaseActivity;
import com.sskj.lib.bean.UserData;
import com.sskj.lib.model.room.UserViewModel;
import com.sskj.lib.util.AppCircleCheckUtil;
import com.sskj.market.R;
import com.sskj.market.R2;
import com.sskj.market.component.DaggerUserDataComponent;
import com.sskj.market.presenter.OrderListPresenter;

import java.util.ArrayList;

import javax.inject.Inject;

import butterknife.BindView;

/**
 * @author budou
 */
@Route(path = RConfig.MARKET_MY_ORDER_LIST)
public class OrderListActivity extends BaseActivity<OrderListPresenter> {


    @BindView(R2.id.tvReturn)
    TextView tvBack;
    @BindView(R2.id.tab_order_list_market)
    SlidingTabLayout tabOrderListMarket;
    @BindView(R2.id.viewpager_order_list_market)
    ViewPager viewpagerOrderListMarket;
    private String[] title = new String[]{App.INSTANCE.getString(R.string.market_orderListActivity1), App.INSTANCE.getString(R.string.market_orderListActivity2), App.INSTANCE.getString(R.string.market_orderListActivity3), App.INSTANCE.getString(R.string.market_orderListActivity4), App.INSTANCE.getString(R.string.market_orderListActivity5)};


    @Override
    protected int getLayoutId() {
        return R.layout.market_activity_order_list;
    }

    @Override
    public OrderListPresenter getPresenter() {
        return new OrderListPresenter();
    }

    @Override
    protected void initView() {
        super.initView();

        ArrayList<Fragment> fragments = new ArrayList<>();
        for (int i = 0; i < title.length; i++) {
            Fragment fragment = new OrderItemFragment();
            Bundle bundle = new Bundle();
            bundle.putInt("orderType", i);
            fragment.setArguments(bundle);
            fragments.add(fragment);
        }
        viewpagerOrderListMarket.setAdapter(new MyFragmentPagerAdapter(getSupportFragmentManager(), fragments));
        tabOrderListMarket.setViewPager(viewpagerOrderListMarket, title);
        setTitle(App.INSTANCE.getString(R.string.market_orderListActivity6));
        tvBack.setVisibility(View.VISIBLE);
        tabOrderListMarket.setOnTabSelectListener(new OnTabSelectListener() {
            @Override
            public void onTabSelect(int position) {
//                RxBus.getDefault().send(position);
            }

            @Override
            public void onTabReselect(int position) {

            }
        });


    }

    @Override
    protected void initData() {
        super.initData();
    }

    @Override
    protected void initEvent() {
        super.initEvent();

    }
}
